package cn.z2huo.demo.spring.cloud.alibaba.provider;

import cn.z2huo.demo.spring.cloud.alibaba.provider.config.ProviderConfiguration;
import cn.z2huo.demo.spring.cloud.alibaba.provider.config.ProviderConfiguration2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * <p>
 *
 * @author z2huo
 */
@Slf4j
@SpringBootApplication
@EnableDiscoveryClient
public class CloudAlibabaProviderApp {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(CloudAlibabaProviderApp.class, args);

        ProviderConfiguration configuration = context.getBean(ProviderConfiguration.class);
        ProviderConfiguration2 configuration2 = context.getBean(ProviderConfiguration2.class);
        log.info("properties after startup, name = {}, age = {}", configuration.getName(), configuration.getAge());
        log.info("properties after startup, userCode = {}, userName = {}", configuration2.getUserCode(), configuration2.getUserName());

        ConfigurableEnvironment environment = context.getEnvironment();
        String kafkaProperty = environment.getProperty("custom.kafka");
        String redisProperty = environment.getProperty("custom.redis");

        log.info("custom kafka = {}", kafkaProperty);
        log.info("custom redis = {}", redisProperty);
    }

}
